<?php
 
 class Post_Model_Media extends Zend_Db_Table
{
        protected $_name="media";
        protected $_primary = 'id';
	   
    public function insertMedia($arrParam = null, $option = null)
  	{
  		$row = $this->fetchNew();		  	
		$row->userid       =$arrParam['userid'];
		$row->link           =$arrParam['link'];
		$row->description       =$arrParam['description'];
		$row->postid       =$arrParam['postid'];
	  	$row->save();
  	}
  	
	
	public function listItemByPost($idpost){

  		$db = Zend_Registry::get('connectDB');		
		$sql = "SELECT *  FROM media where postid =  '".$idpost."'";
  		$result = $db->fetchAll($sql);
  	
  		return $result;
  	}
  	
  	
	public function listItem($arrParam = null, $option = null){

  		$db = Zend_Registry::get('connectDB');		
		$sql = "SELECT *  FROM media where postid =  '".$arrParam['postid']."'  ";
  		$result = $db->fetchAll($sql);
  	
  		return $result;
  	}
  	
  	public function getItemByPost($arrParam = null, $option = null){

  		$db = Zend_Registry::get('connectDB');		
		$sql = "SELECT *  FROM media where postid =  '".$arrParam['postid']."'  ";
  		$result = $db->fetchRow($sql);
  	
  		return $result;
  	}
  	
  	
	public function updateMedia($arrParam = null, $option = null)
	{
		$db = Zend_Registry::get('connectDB');	
		$where = array(
    		'id = ?' => $arrParam['id'],
			'userid = ?' => $arrParam['userid'],		
		);	
		$data  = array(
			"postid"=>$arrParam['postid'],			
		);
		$db->update("media", $data, $where);
	}

}
    
    

?>